home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 10241 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.3 KB

  1. Path: news.primenet.com!not-for-mail
  2. From: gbe@primenet.com (Gary Edstrom)
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: Random number generator
  5. Date: 6 Mar 1996 13:40:02 -0700
  6. Organization: Sequoia Software
  7. Sender: root@primenet.com
  8. Message-ID: <313df6b0.84776542@news.primenet.com>
  9. References: <00001a81+0000ab27@msn.com>
  10. X-Posted-By: ip144.lax.primenet.com
  11. X-Newsreader: Forte Agent .99d/32.182
  12.  
  13. On 6 Mar 96 16:50:49 -0800, Tony_Bateman@msn.com (Tony Bateman) wrote:
  14.  
  15. >I need to write/acquire a good random number generator.
  16. >
  17. >Anybody have any source code in C++ or the address of a site where I 
  18. >could download the code?
  19.  
  20. One of the best formulas is from Knuth in his "Seminumerical
  21. Algorithms" volume of "The Art of Computer Programming" series and is
  22. as follows:
  23.  
  24. X(n+1) = ( 6,364,136,223,846,793,005 * X(n) + 1 ) mod 2^64
  25.  
  26. This formula has a period of 2^64 numbers before it starts to repeat
  27. and it has excellent randomness.
  28.  
  29. EMail me if you would like an x86 compatible assembly language version
  30. of the code.  I also have a C++ in-line assembly language version of
  31. the code.
  32.  
  33. --
  34. Gary Edstrom <gbe@primenet.com> | Sequoia Software
  35. PO Box 9573                     | Programming & Technical Services
  36. Glendale CA 91226-0573          | PGP Key ID: 0x1A0D44BD
  37. PGP Fingerprint: 72 AA 4F 73 05 53 89 C6  8A EE F4 EE D1 C0 13 8D 
  38.